package YourSpaceDB::Blog;
# $WCREV WVDATE$
use base qw/DBIx::Class/;

__PACKAGE__->load_components(qw/PK::Auto Core/);
__PACKAGE__->table('blog');
__PACKAGE__->add_columns(qw/ 

blog_id
blog_author
blog_title
blog_tags
blog_date
blog_text
blog_is_hidden
blog_rating
blog_parent
blog_is_reply
blog_is_draft
blog_attachment
blog_last_accessed
/);
 
__PACKAGE__->set_primary_key('blog_id');


## Thanks to YourMother of Perlmonks
__PACKAGE__->belongs_to('blog_parent' => __PACKAGE__);
__PACKAGE__->has_many('replies' => __PACKAGE__, 'blog_parent',
                      undef,
                      { order_by => 'blog_date' } );

sub parents {
    my ( $self, @parents ) = @_;
    my $parent = $self->parent;
    return @parents unless $parent;
    push @parents, $parent;
    die "Endless lineage loop suspected!" if @parents > 100;
    $parent->parents(@parents);
}
####
1;